<template>
  <div style="margin-top:15px;">
    <!--订单信息-->
    <OrderInfo :chOrderService="headerDetail" :routeName="routeName"></OrderInfo>
    <!--客户信息：服务订单才有-->
    <UserInfo :chOrderConsigneeInfo="chOrderConsigneeInfo" v-if="headerDetail.orderType === 'STORAGEORDERTYPE01'"></UserInfo>
    <!--商品信息-->
    <PackageTable :value="productDetailBeans" :productType="productType" :totalInfo="headerDetail"></PackageTable>
  </div>
</template>
<script>
import OrderInfo from '@/views/oms/outputWarehouse/warehousingOrder/OrderInfo'
import UserInfo from '@/views/oms/outputWarehouse/warehousingOrder/UserInfo'
import PackageTable from '@/views/oms/business/PackageTable'
import {dotData} from '@/utils'
export default {
  name: 'outputWarehouseOrderShow',
  components: {
    OrderInfo,
    PackageTable,
    UserInfo
  },
  data() {
    return {
      id: this.$route.params.id,
      routeName: this.$route.name,
      headerDetail: {}, // 订单信息
      productDetailBeans: [], // 货物包件信息
      chOrderConsigneeInfo: {} // 用户信息
    }
  },
  created() {
    this.getHeader()
    this.getTableArr()
  },
  computed: {
    // 标准产品1，通用产品2==自定义产品3
    productType() {
      return dotData(this.headerDetail, 'productType') || 1 // 默认为标准产品
    }
  },
  methods: {
    getHeader() {
      this.$ajax.get('/ms-warehouse-order/outWarehose/findByOrderInfo', {outOrderId: this.id}).then(response => {
        if (!response.success) {
          return
        }
        // 订单信息
        this.headerDetail = response.data || {}
        // 客户信息
        this.chOrderConsigneeInfo = this.headerDetail.chOrderConsigneeInfo || {}
      })
    },
    // 商品信息
    getTableArr() {
      this.$ajax.get('/ms-warehouse-order/outWarehose/findByOutWarehouseInfo', {outOrderId: this.id}).then(response => {
        if (response.success) {
          console.log('请求回来的包件table信息', response.data)
          this.productDetailBeans = response.data || []
        }
      })
    }
  }
}
</script>
